<template>
  <div style="display: inline-block; margin: 0 12px">
    <el-button type="primary" @click="exampleImportOpen">模板导入</el-button>
    <HfDrawer title="模板导入" ref="exampleImportRef">
      <template #content>
        <div class="topTip">tip:快双击模板试试吧！</div>
        <div class="exampleItemBox">
          <div class="exampleItemed" @dblclick="exampleImportFn(item)" v-for="item in exampleList" :key="item.key">
            <div class="exampleItem">
              <div class="exampleItem1">{{ item.label }}</div>
              <img class="exampleItem2" src="https://pics-test.xiu361.cn/52a-01.jpg" alt="" />
            </div>
          </div>
        </div>
      </template>
    </HfDrawer>
  </div>
</template>
<script setup lang="ts">
import { importJSON } from "@/views/coderCreate/index";
import exampleList from "./index";
const exampleImportRef = ref();
function exampleImportOpen() {
  exampleImportRef.value.compontOpen = true;
}
async function exampleImportFn(item: renderTypemExample) {
  const ab = await import(`./example/${item.key}.ts`);
  importJSON(JSON.stringify(ab.default));
  return;
}
</script>
<style scoped lang="scss">
.topTip {
  color: #544343;
  background-color: rgb(238 238 238);
  border: 1px solid #dac0c0;
  border-radius: 5px;
  font-size: 14px;
  padding: 10px;
}
.exampleItemBox {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  .exampleItemed {
    width: 50%;
    display: flex;
    justify-content: center;
    .exampleItem {
      margin-top: 10px;
      border: 1px solid #e6e6e6;
      border-radius: 5px;
      font-size: 14px;
      padding: 10px;
      .exampleItem1 {
        margin-bottom: 5px;
      }

      .exampleItem2 {
        height: 150px;
        width: 250px;
      }
    }
  }
}
</style>
